package com.interesting.client.widget.dialog;

import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.Fragment;

import com.actionbarsherlock.app.SherlockDialogFragment;
import com.interesting.R;
import com.interesting.client.UI.home.MenuFragment;
import com.interesting.client.application.AppHolder;

public class LogoutDialogFragment extends SherlockDialogFragment implements DialogInterface.OnClickListener {

	private String[] items = new String[] { "注销账户" };

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setStyle(DialogFragment.STYLE_NO_TITLE, 0);
	}

	@Override
	public Dialog onCreateDialog(Bundle savedInstanceState) {
		AlertDialog.Builder builder = new AlertDialog.Builder(getSherlockActivity());
		builder.setTitle("是否要");
		builder.setItems(items, this);

		return builder.create();
	}

	public void cancel() {

	}

	@Override
	public void onClick(DialogInterface dialog, int which) {

		AppHolder.getInsatnce().user.setUserId(null);
		AppHolder.getInsatnce().user.setUserName(null);
		AppHolder.getInsatnce().user.setUserIcon(null);
		Fragment fragment = getFragmentManager().findFragmentById(R.id.main_activity_menu);
		if (fragment instanceof MenuFragment) {
			((MenuFragment)fragment).refresh();
		}
	}

}
